<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <title>Document</title>
    <style>
        .box{
            width: 500px;
            height: 500px;
            border: solid 1px;
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div id="app">
        <button v-on:click="show = !show">反转</button>
        <p v-show="show">默认显示，点击隐藏</p>
        <div class="box">
            <img v-bind:src="src" alt="">
        </div>
        <button v-on:click="changImg">切换图片</button>
        
    </div>

    <script>
        let  vm = new Vue({
            el:"#app",
            data:{
                show:true,
                src:"https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png",
                num:0
            },
            methods:{
                changImg(){
                    // 先设置一个值为0，在通过值的变化改变src的路径，实现改变
                    if(this.num === 0 ){
                        this.src ="https://www.google.cn/landing/cnexp/google-search.png"
                        this.num = 1
                    }else if(this.num === 1){
                        this.src = "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png"
                        this.num = 0
                    }
                }
            }
        })
    </script>


</body>
</html>